import random

# computer= ['石头', '剪刀', '布']
# while True :
#     cptChoice = random.choice(computer)
#     userChoice = input("请出拳\n=====================\n输入‘退出’退出游戏\n=====================")
#     if userChoice == '退出':
#         print('您已退出游戏')
#         break
#     if userChoice not in computer:
#         print('请按照规则出拳，请重新出拳')
#         continue
#     print(f'你出了{userChoice}')
#     print(f'电脑出了{cptChoice}')
#     if userChoice == cptChoice:
#         print("平局！")
#     elif userChoice == "石头" and cptChoice == "剪刀":
#         print("你赢了！")
#     elif userChoice == "剪刀" and cptChoice == "布":
#         print("你赢了！")
#     elif userChoice == "布" and cptChoice == "石头":
#         print("你赢了！")
#     else:
#         print("你输了！")


com= ['石头','剪刀','布']

while True:

    player = input('请出拳，输入q退出。')
    computer = random.choice(com)
    print(f'你的选择{player}')
    print(f'电脑的选择{computer}')
    if player == 'q':
        print('欢迎下次再来')
        break
    if player == computer :
        print('平手')
    if player == '石头' and computer == '剪刀':
        print('你赢了')
    elif player == '剪刀' and computer == '布':
        print('你赢了')
    elif player == '布' and computer == '石头':
        print('你赢了')
    else:
        print('你输了')


